DIFF = {
    "e": (1, 0),
    "w": (-1, 0),
    "se": (0, 1),
    "sw": (-1, 1),
    "ne": (1, -1),
    "nw": (0, -1),
}

with open('input.txt') as file:
    black = set()

    for line in file.read().splitlines():
        q, r = 0, 0
        while line:
            for k, (qd, rd) in DIFF.items():
                if line.startswith(k):
                    line = line[len(k):]
                    q += qd
                    r += rd
        if (q, r) in black:
            black.remove((q, r))
        else:
            black.add((q, r))

    print(len(black))